layui.use('form', function() {
	var form = layui.form;
	
	form.verify({
		Percentage : function(value, item) { // value：表单的值、item：表单的DOM对象
            if (parseInt(value) <= 0 || parseInt(value)> 100 ) {
                 return '分销比例只能在0-100%';
            }
        }
      
   });
	
	
	$.post("distributionGoodsInquiry.do", function(data) {
		var html = "";
		for (var i = 0; i < data.data.length; i++) {
			html += "<option value=" + data.data[i].cId + ">"
					+ data.data[i].cName + "</option>"
		}
		$("#shop").html(html);
		layui.form.render(); 
	}, "json")
	// 监听提交
	form.on('submit(formDemo)', function(data) {

		layer.confirm("配置分销确认？", {
			title : "确认"
		}, function(index) {
			$.post("DistributionConfigurationAddition.do", {
				cId : data.field.cId,
				FirstClassCommission : data.field.one,
				TwoStageReturnCommission : data.field.two,
				ThreeStageReturnCommission : data.field.three
			}, function(res) {
				if (res.type == 1) {
					layer.msg("添加成功");
					window.location.reload();
				}
			}, "json")
		})

		return false;
	});
});